#ifndef _DOGE_DEVICE_H_
#define _DOGE_DEVICE_H_
 

typedef struct dg_device  dg_device_t;
 
struct dg_device_ops {
    int  (*init)   (dg_device_t *dev);
    int  (*open)   (dg_device_t *dev, int oflag);
    int  (*close)  (dg_device_t *dev);
    int  (*read)   (dg_device_t *dev, int pos, void *buffer, int size);
    int  (*write)  (dg_device_t *dev, int pos, const void *buffer, int size);
    int  (*control)(dg_device_t *dev, int cmd, void *args);
};
 
struct dg_device {
    const char * name;
    struct dg_device_ops *dops;
    struct dg_device *next;
};
 
int dg_device_register(dg_device_t *dev);
dg_device_t *dg_device_find(const char *name);
int dg_device_read(dg_device_t *dev,  int pos, void *buffer, int size);
int dg_device_write(dg_device_t *dev, int pos, const void *buffer, int size);
int dg_device_ctrl(dg_device_t *dev,  int cmd, void *arg);
 
#endif
